package com.study.iostream;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/**
 * <p>添加类描述</p>
 *
 * @author chentao
 * @version v 0.1 2021/1/2 22:48
 */
public class FileReaderAndWriter {
    public static void main(String[] args) throws IOException {
        FileReader reader = new FileReader("F:\\test\\file\\from.txt");

        //1024大小的字符数组
        char[] buf = new char[1024];

        //reader读取字符，将读取的字符存入buf中。len为读取的字符数。
        int len = reader.read(buf);

        //读取完毕后。释放资源
        reader.close();

        //打印读取的信息
        String str = new String(buf, 0, len);
        System.out.println();

        FileWriter writer = new FileWriter("F:\\test\\file\\to.txt");

        //将读取的信息写入to.txt
        //writer.write(str);
        //将读取的信息写入to.txt
        writer.write(buf,0,len);
        //写入完成后，释放资源
        writer.close();
    }
}
